<%@page import="servlet.AuditLogTable"%>
<%@page import="Logic.Authorizer"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%
	if (session.getAttribute("name") == null) {
		response.sendRedirect("login.jsp");
	} else {
		if (!Authorizer.checkRole("4", session.getAttribute("role")
				.toString())) {
			response.sendRedirect("nopermission.jsp");
		}
	}
%>

<!-- Declare the first header -->
<jsp:include page="t_header.jsp" />

<!-- Declare Breadcrumbs options -->
<div class="breadcrumbs_container">
	<article class="breadcrumbs">
		<a href="role_view.jsp">Audit Log</a>
		<div class="breadcrumb_divider"></div>
		<a class="current">View Audit Log</a>
	</article>
</div>
<jsp:include page="header.html" />
<!-- Declare sidebar -->
<jsp:include page="t_sidebar.jsp" />

<!-- Main Content -->
<section id="main" class="column">
	<%
		if (request.getParameter("error") != null) {
			if (request.getParameter("error").equals("-1"))
				out.print("<h4 class='alert_info'>Audit log clear.</h4>");
		}
	%>
	<%
		if (request.getParameter("action") != null
				&& request.getParameter("action").equals("d")) {
	%>
	<article class="module width_3_quarter">
		<form action="ClearAuditLog" method="POST">
			<header>
				<h3>Confirm Clear?</h3>
			</header>
			<div class="module_content">
				<h2>Are you sure you want to clear the audit log? You cannot
					undo this action!</h2>
				<div class="clear"></div>
			</div>
			<footer>
				<div class="submit_link">
					<input type="submit" name="submit" value="Confirm Clear"
						class="alt_btn"> <input type="submit" name="submit"
						value="Cancel" class="alt_btn">

				</div>
			</footer>
		</form>
	</article>
	<%
		} else {
	%>
	<article class="module width_3_quarter" style="margin-bottom:20px;">

		<header>
			<h3>View Audit Log</h3>
		</header>


		<table class="tablesorter" cellspacing="0">
			<thead>
				<tr>
					<th>Staff ID</th>
					<th>Action</th>
					<th>Time</th>
				</tr>
			</thead>
			<tbody>
				<%
					AuditLogTable table = new AuditLogTable(out);
						table.doGet(request, response);
				%>
			</tbody>
		</table>


		<form action="auditlog_view.jsp?action=d" method="post">
			<footer>
				<div class="submit_link">
					<input type="submit" value="Clear Log" class="alt_btn">
				</div>
			</footer>
		</form>

	</article>
	<%
		}
	%>
	<!-- end of content manager article -->
	<div > </div>
</section>

<!-- Declare closing tags -->
<jsp:include page="t_footer.jsp" />